Page({
    data: {
		pass:false,
        buttons: [{
                type: 'balanced',
                block: true,
                text: '查看订单',
            },
            {
                type: 'light',
                block: true,
                text: '返回首页',
            },
        ],
    },
    onClick(e) {
        console.log(e)
		var that = this
        var index = e.detail.index
		if(index){
			if(that.data.pass){
				wx.switchTab({url:"../my/paypsw/paupsw"})
			}
			wx.switchTab({url:"../index/index"})
		}else{
			wx.redirectTo({url:"../shopping/orderlist/orderlist?id="+that.data.orderid})
		}
    },
	onLoad(option) {
		// 获取用户信息
		var that = this
		that.setData({
			orderid:option.orderid
		})
		
		// 获取用户信息
		var userinfo = wx.getStorageSync("userinfo");
		// 如果用户还没有设置支付密码
		if(!userinfo.paypassword){
			var button = that.data.buttons;
			button[1].text = "设置支付密码";
			that.setData({
				buttons:button,
				pass:true
			})
		}
	},
})